ReadOnly Generic Method

Wintellect PowerCollections

Collapse imageExpand ImageCollapseAll imageExpandAll imageDropDown imageDropDownHover imageCopy imageCopyHover image
[This topic is pre-release documentation and is subject to change in future releases. Blank topics are included as placeholders.]

Returns a read-only view onto a collection. The returned ICollection<T> interface only allows operations that do not change the collection: GetEnumerator, Contains, CopyTo, Count. The ReadOnly property returns false, indicating that the collection is read-only. All other methods on the interface throw a NotSupportedException.

Namespace: Wintellect.PowerCollections
Assembly:  PowerCollections (in PowerCollections.dll)

Syntax

C#
public static ICollection<T> ReadOnly<T>(
	ICollection<T> collection
)
Visual Basic (Declaration)
Public Shared Function ReadOnly(Of T) ( _
	collection As ICollection(Of T) _
) As ICollection(Of T)
Visual C++
public:
generic<typename T>
static ICollection<T>^ ReadOnly (
	ICollection<T>^ collection
)

Parameters

collection
ICollection<(Of <T>)>
The collection to wrap.

Return Value

A read-only view onto collection. If collection is null, then null is returned.

Type Parameters

T
The type of items in the collection.

Remarks

The data in the underlying collection is not copied. If the underlying collection is changed, then the read-only view also changes accordingly.

See Also